﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Com.CMS263.BLL;
using Com.CMS263.PO;
using Com.CMS263.Util;

namespace Com.CMS263.Web
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }
        

        protected void Button1_Click(object sender, EventArgs e)
        {
            string uid = StringUtil.checkStr(User_Name.Text);
            string pwd = StringUtil.checkStr(User_Password.Text);
            string code = Request["ValidCode"];
            string recode = Convert.ToString(Session["code"]);
            if (uid == "" || pwd == "")
            {
                StringUtil.Alert("账号或密码不能为空", "-1");
            }
            else if (code == "")
            {
                StringUtil.Alert("请输入验证码", "-1");
            }
            else if (!code.ToLower().Equals(recode.ToLower()))
            {
                StringUtil.Alert("验证码输入错误", "-1");
            }
            else
            {
                CustomerListBLL clbll = new CustomerListBLL();

                if (clbll.FindModelByuserNameAndPass(uid, pwd))
                {
                    StringUtil.Alert("登录成功", "/download.aspx");
                }
                else
                {
                    StringUtil.Alert("登录失败请重试", "-1");
                }

            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("register.aspx");
        }
    }
}
